using System;
using System.ComponentModel.DataAnnotations;

namespace JGSY.CMS.LowCode.Platform.Application.DTOs
{
    /// <summary>
    /// 工作流数据传输对象
    /// 用于传输工作流相关的数据信息，包括流程定义、节点配置等
    /// </summary>
    public class WorkflowDto
    {
        /// <summary>
        /// 工作流ID
        /// </summary>
        public long Id { get; set; }

        /// <summary>
        /// 工作流名称
        /// </summary>
        [Required(ErrorMessage = "工作流名称不能为空")]
        [StringLength(255, ErrorMessage = "工作流名称长度不能超过255个字符")]
        public string Name { get; set; } = string.Empty;

        /// <summary>
        /// 工作流标识符
        /// </summary>
        [Required(ErrorMessage = "工作流标识符不能为空")]
        [StringLength(100, ErrorMessage = "工作流标识符长度不能超过100个字符")]
        public string Identifier { get; set; } = string.Empty;

        /// <summary>
        /// 工作流描述
        /// </summary>
        [StringLength(500, ErrorMessage = "工作流描述长度不能超过500个字符")]
        public string? Description { get; set; }

        /// <summary>
        /// 工作流分类
        /// </summary>
        [StringLength(100, ErrorMessage = "工作流分类长度不能超过100个字符")]
        public string? Category { get; set; }

        /// <summary>
        /// 流程定义（JSON格式）
        /// </summary>
        public string? Definition { get; set; }

        /// <summary>
        /// 节点配置（JSON格式）
        /// </summary>
        public string? Nodes { get; set; }

        /// <summary>
        /// 连接配置（JSON格式）
        /// </summary>
        public string? Connections { get; set; }

        /// <summary>
        /// 变量配置（JSON格式）
        /// </summary>
        public string? Variables { get; set; }

        /// <summary>
        /// 条件配置（JSON格式）
        /// </summary>
        public string? Conditions { get; set; }

        /// <summary>
        /// 权限配置（JSON格式）
        /// </summary>
        public string? Permissions { get; set; }

        /// <summary>
        /// 通知配置（JSON格式）
        /// </summary>
        public string? Notifications { get; set; }

        /// <summary>
        /// 超时设置（JSON格式）
        /// </summary>
        public string? Timeouts { get; set; }

        /// <summary>
        /// 是否启用版本控制
        /// </summary>
        public bool EnableVersionControl { get; set; }

        /// <summary>
        /// 流程版本
        /// </summary>
        [StringLength(50, ErrorMessage = "流程版本长度不能超过50个字符")]
        public string? ProcessVersion { get; set; }

        /// <summary>
        /// 是否自动启动
        /// </summary>
        public bool AutoStart { get; set; }

        /// <summary>
        /// 优先级
        /// </summary>
        [Range(1, 10, ErrorMessage = "优先级范围为1-10")]
        public int Priority { get; set; } = 5;

        /// <summary>
        /// 最大并发数
        /// </summary>
        [Range(1, int.MaxValue, ErrorMessage = "最大并发数必须大于0")]
        public int? MaxConcurrency { get; set; }

        /// <summary>
        /// 执行次数
        /// </summary>
        public int ExecutionCount { get; set; }

        /// <summary>
        /// 成功次数
        /// </summary>
        public int SuccessCount { get; set; }

        /// <summary>
        /// 失败次数
        /// </summary>
        public int FailureCount { get; set; }

        /// <summary>
        /// 平均执行时间（秒）
        /// </summary>
        public decimal? AverageExecutionTime { get; set; }

        /// <summary>
        /// 最后执行时间
        /// </summary>
        public DateTime? LastExecutedAt { get; set; }

        /// <summary>
        /// 排序权重
        /// </summary>
        public int SortOrder { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public byte Status { get; set; }

        /// <summary>
        /// 版本号
        /// </summary>
        public int Version { get; set; }

        /// <summary>
        /// 创建人ID
        /// </summary>
        public long CreatedBy { get; set; }

        /// <summary>
        /// 修改人ID
        /// </summary>
        public long? UpdatedBy { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedAt { get; set; }

        /// <summary>
        /// 修改时间
        /// </summary>
        public DateTime UpdatedAt { get; set; }

        /// <summary>
        /// 创建人姓名
        /// </summary>
        public string? CreatorName { get; set; }

        /// <summary>
        /// 修改人姓名
        /// </summary>
        public string? UpdaterName { get; set; }

        /// <summary>
        /// 状态文本
        /// </summary>
        public string? StatusText { get; set; }

        /// <summary>
        /// 成功率
        /// </summary>
        public decimal? SuccessRate { get; set; }

        /// <summary>
        /// 是否运行中
        /// </summary>
        public bool IsRunning { get; set; }

        /// <summary>
        /// 当前实例数
        /// </summary>
        public int CurrentInstances { get; set; }
    }
}
